Klasse PDFComparer

java.lang.Object
com.inet.pdfc.PDFComparer

public class PDFComparer extends Object
This is the main entry point when using i-net PDFC API. The PDFComparer can compare two files or folders and allows the user to add presenters to show the result.

Typical Usage:

File referenceFile = new File( args[0] ); // first document file
File currentFile = new File( args[1] ); // second document file

IProfile profile = new DefaultProfile();
profile.putObject( PDFCProperty.CONTINUOUS_COMPARE, Boolean.TRUE );

new PDFComparer().setProfile( profile ).addPresenter( new ConsolePresenter() ).compare( referenceFile, currentFile );

Seit:
i-net PDFC 3.0
  • Konstruktordetails

    • PDFComparer

      public PDFComparer() throws RuntimeException, com.inet.pdfc.generator.InvalidLicenseException
      Creates an empty comparer instance. Call setProfile(IProfile) to configure the comparer, addPresenter(BasePresenter) to add output modules and start the comparison with compare(File, File) or batchCompare(File, File)
      Löst aus:
      RuntimeException - A runtime exception will be thrown here if and only if there is no valid license which grants API permissions.
      com.inet.pdfc.generator.InvalidLicenseException - thrown in case there is no license for i-net PDFC or, if the license is insufficient for the API.
      Seit:
      i-net PDFC 3.0
  • Methodendetails

    • setProfile

      public PDFComparer setProfile(IProfile profile)
      Set the profile to use with this PDFComparer.
      The profile determines which elements must be compared, how large the tolerance must be and other options.
      Parameter:
      profile - the profile to use, must not be null.
      Gibt zurück:
      this PDFComparer, allowing additional methods to be called in a chain.
      Seit:
      i-net PDFC 4.0
    • setProfile

      public PDFComparer setProfile(String profileID) throws IllegalArgumentException
      Set the profile to use with this PDFComparer.
      The profile determines which elements must be compared, how large the tolerance must be and other options.
      It's recommended to check whether the profile is available first by calling DefaultProfileID.getAvailableProfileIDs(). All Available default profiles can be listed by DefaultProfileID.getAvailableProfileIDs().
      Parameter:
      profileID - the ID or name of the profile to be used. Please note, that the names of default profiles are localized, so use their ID instead.
      Gibt zurück:
      this PDFComparer, allowing additional methods to be called in a chain.
      Löst aus:
      IllegalArgumentException - thrown if no such profile could be found either by ID or name.
      Seit:
      i-net PDFC 4.0
      Siehe auch:
    • addPresenter

      public PDFComparer addPresenter(BasePresenter presenter)
      Adds a Presenter to this PDFComparer.
      A presenter is responsible to 'present' the comparison result, like print found differences on the console or create difference images.
      Parameter:
      presenter - the presenter to add, must not be null.
      Gibt zurück:
      this PDFComparer, allowing additional methods to be called in a chain.
      Seit:
      i-net PDFC 3.0
      Siehe auch:
    • compare

      public ResultModel compare(File document1, File document2) throws PdfcException
      Compare the two given PDF-Files located on the file system.
      This method is blocking! Use compareAsync(PdfSource, PdfSource) for a non-blocking comparison.
      Parameter:
      document1 - the first document to compare, make sure to have reader plugin for the type of document
      document2 - the second document to compare, make sure to have reader plugin for the type of document
      Gibt zurück:
      a ResultModel containing result-information about the comparison.
      Löst aus:
      PdfcException - when comparison faced an error
      IllegalArgumentException - in case document cannot be accessed or is a directory
      Seit:
      i-net PDFC 3.0
    • compare

      public ResultModel compare(PdfSource pdf1, PdfSource pdf2) throws PdfcException
      Compare the two given documents located anywhere.
      This method is blocking! Use compareAsync(PdfSource, PdfSource) for a non-blocking comparison.
      Parameter:
      pdf1 - the first document to compare, make sure to have reader plugin for the type of document
      pdf2 - the second document to compare, make sure to have reader plugin for the type of document
      Gibt zurück:
      a ResultModel containing result-information about the comparison.
      Löst aus:
      PdfcException - in case of an internal exception
      Seit:
      i-net PDFC 3.0
    • batchCompare

      public void batchCompare(File directory1, File directory2)
      Compare the two given directories, always comparing document files with the same name.
      This method is blocking! Use compareAsync(PdfSource, PdfSource) for a non-blocking comparison.
      Parameter:
      directory1 - the first directory to use, must be a directory.
      directory2 - the second directory to use, must be a directory.
      Löst aus:
      IllegalArgumentException - thrown in case the directory is not readable or not a directory
      Seit:
      i-net PDFC 3.0
    • batchCompare

      public void batchCompare(DirectoryPdfSource directory1, DirectoryPdfSource directory2)
      Compare the two given directories, always comparing PdfSources with the same name.
      Parameter:
      directory1 - the first directory to use, must not be null.
      directory2 - the second directory to use, must not be null.
      Seit:
      i-net PDFC 3.0
    • isCreateTextSelectionData

      protected boolean isCreateTextSelectionData()
      Defines whether the comparer creates the TextInfoImpl data for the ResultModel as well. This data may require a large amount of memory depending on the text size. It should only be enabled if the protected method getTextInfos() of the ResultPages is used! Otherwise it's a waste of performance and memory.
      Gibt zurück:
      returns false by default
      Seit:
      i-net PDFC 3.2
    • setSettings

      public PDFComparer setSettings(Settings settings)
      Defines the visibility for difference option. For example can be set the visibility for filter highlights or difference group types. Default are all highlights for inactive filters or filters not mentioned in this list. So, by default, all highlights are deactivated Default are all public difference group types visible.
      Parameter:
      settings - the filters to activate the highlights for.
      Gibt zurück:
      this PDFComparer, allowing additional methods to be called in a chain.
      Seit:
      i-net PDFC 4.3
    • compareAsync

      public CompletableFuture<ResultModel> compareAsync(PdfSource document1, PdfSource document2)
      Asynchronously compares the two given documents.
      Parameter:
      document1 - the first document to compare, make sure to have reader plugin for the type of document
      document2 - the second document to compare, make sure to have reader plugin for the type of document
      Gibt zurück:
      a worker object to wait for the result or to cancel the process
      Löst aus:
      IllegalStateException - if the same comparer is used to start several async comparisons
      Seit:
      4.0
    • getAvailableCompareModeKeys

      public static List<String> getAvailableCompareModeKeys()
      Returns the keys of all compare modes that are available to the application. The returned values can be used as values for the PDFCProperty.CONTINUOUS_COMPARE property.
      Compare algorithms are plugins an thus can be removed or deactivated.
      Gibt zurück:
      the keys of all compare modes that are available to the application
      Seit:
      4.0
    • getAvailableFilterKeys

      public static List<String> getAvailableFilterKeys()
      Returns the keys of all filters that are available to the application. The returned values can be used as values for the PDFCProperty.FILTERS property.
      Filters are plugins an thus can be removed or deactivated. It's recommended to check for valid filters when modifying a profile.d
      Gibt zurück:
      the keys of all filters that are available to the application
      Seit:
      4.0
    • getPresenterExceptions

      public List<PresenterExceptionData> getPresenterExceptions()
      Return the exceptions that occurred during the comparison which have not led to an interruption of the comparison.
      Gibt zurück:
      all exception in the presenters
      Seit:
      5.0